package com.lagou.edu.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author Kirito
 * @description:
 * @date 2020/04/11
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public ModelAndView handleException(Exception e) {
        ModelAndView view = new ModelAndView();
        view.addObject("message", "服务器异常，请与管理员联系!");
        view.setViewName("login");
        return view;
    }

}
